#!/usr/bin/env python
import sys
sys.path.append("../python")
import edbcli
from subprocess import *
import time

if __name__ == "__main__":
	pid = Popen(["../edb", "-S"]).pid
	print("edb pid: "+str(pid))
	time.sleep(1)	# wait for prog to start
	
	edb = edbcli.Client(["127.0.0.1:11911"])
	
	# insert test (on non-_name attribute):
		
	c = 10
	
	for x in range(c):
		results = edb.query("INSERT INTO test_domain VALUES( x:$x );", [{"x":x}])

	results = edb.query("SELECT * FROM test_domain;", [])
	if len(results) != c:
		print("FAILURE")
	else:
		print("OK")
	
	# kill edb:
	kill_pid = Popen(["/usr/bin/env", "kill", "-s", "INT", str(pid) ]).pid	